class Account: def __init__(self,an,bl): self.accno=an self.balance=bl def deposit(self,amt): self.balance=self.balance+amt def withdraw(self,amt): self.balance=self.balance-amt def showBalance(self): print("AccNo :",self.accno) print("Balance :",self.balance) a=Account(4117,5000) a.showBalance() a.deposit(3000) a.showBalance() a.withdraw(2000) a.showBalance()
AccNo : 4117 Balance : 5000 AccNo : 4117 Balance : 8000 AccNo : 4117 Balance : 6000
class worker: def __init__(self,n,w,d): self.name=n self.wages=w self.wdays=d def showData(self): print("Name is ",self.name) print("Wages is ",self.wages) print("Wdays is ",self.wdays) def payment(self): p=self.wages*self.wdays print("Payment is ", p) def addwdays(self,n): self.wdays=self.wdays+n a=worker("Raja",500,5) a.showData() a.payment() a.addwdays(2) a.payment()
Name is Raja Wages is 500 Wdays are 5 Payment is 2500 Payment is 3500